package twoD.Csg.tests;

import junit.framework.Assert;

import org.junit.Test;

import twoD.Csg.IPrimitive;
import twoD.Csg.Rectangle;
import twoD.Csg.Rotation;
import twoD.Csg.Transformation;
import twoD.Csg.Translation;

public class RectangleTest {

	@Test
	public void testCheck() {
		IPrimitive P = new Rectangle(-1, -1, 2, 2);
		double[] p1 = new double[] { 0.5, 0 };
		double[] p2 = new double[] { 1.1, 0 };
		Assert.assertEquals(true, P.contain(p1));
		Assert.assertEquals(false, P.contain(p2));

		Transformation T = new Translation(0.1, 0);
		Transformation R = new Rotation(0, 0, Math.PI / 3);
		Transformation T1 = T.multiply(R);
		Transformation T2 = R.multiply(T);

		P.setTransformation(T1);
		Assert.assertEquals(true, P.contain(p1));
		Assert.assertEquals(true, P.contain(p2));

		P.setTransformation(T2);
		Assert.assertEquals(true, P.contain(p1));
		// System.out.println(ArrayFormat.format(((Circle) C).getCenter()));
		Assert.assertEquals(true, P.contain(p2));
	}

}
